package com.fliad.ai.dto.taskmodel;

import lombok.Data;

@Data
public class StatusData {

    private boolean terminated;
    private WorkflowStatus status;
    private long startTime;
    private long endTime;
    private long timeCost;

    public StatusData() {
        this.terminated = false;
        this.status = WorkflowStatus.processing;
        this.startTime = System.currentTimeMillis();
        this.endTime = System.currentTimeMillis();
        this.timeCost = this.endTime - this.startTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
        this.timeCost = endTime - this.startTime;
    }

    public void setTerminated(boolean terminated) {
        this.terminated = terminated;
        if (terminated) {
            this.status = WorkflowStatus.succeeded;
        }
        setEndTime(System.currentTimeMillis());
    }

}
